package com.bzg.manager.utils;

/**
 * Description:统一的 HTTP 响应格式
 * error 为 "0" 表示业务调用成功，否则是失败的错误码，如果有多个则以逗号分隔。
 * info 是业务数据，如果失败了则是 null。
 * 
 * @author gmy
 * @date 2017年3月2日 上午11:35:47
 */
public class RespBody {
	
    private final Object info;
    private final String error;	
    private final String msg;
   
    public Object getInfo() {
		return info;
	}

	public String getError() {
		return error;
	}

	public String getMsg() {
		return msg;
	}

	private RespBody (Object info,String error,String msg){
    	this.info=info;
    	this.error=error;
    	this.msg=msg;
    }
    
    public static RespBody ok(Object info){
    	if(info == null){
    		info = "";
    	}
    	return new RespBody(info,"0","请求成功！");
    }
    
    public static RespBody ok(Object info,String msg){
    	if(info == null){
    		info = "";
    	}
    	return new RespBody(info, "0", msg);
    }
    
    public static RespBody error(String error,String msg){
    	return new RespBody("", error, msg);
    }
    
    public static RespBody error(Object info,String error,String msg){
    	if(info == null){
    		info = "";
    	}
    	return new RespBody(info, error, msg);
    	
    }
}

